<?php

namespace App\Models;

use App\Http\Consts\OsConsts;
use Illuminate\Database\Eloquent\Model;

class Game extends Model
{
    protected $table = 'games';

    protected $fillable = [
        'name',
        'synopsis',
        'content',
        'show_img_id',
        'carousel_ids',
        'game_type_id',
        'os',
        'version',
        'size',
        'update',
        'a_download',
        'ios_download',
        'owner_id',
        'enable_status',
        'status',
        'created_at',
        'updated_at',
    ];

    public function getCarouselIdsArrAttribute($key)
    {
        return explode(',',$key);
    }

    public function getOsStrAttribute($key){
        return $key;
//        return OsConsts::getStrByCode($key);
    }

    public function getGameTypeStrAttribute($key){
        $map = new Map();
        return $map->where('id',$key)->first()['name'] ?? "";
    }

}
